/**
 * antd类型补充
 */
import type { TableColumnProps } from "ant-design-vue";
import type { validateOptions } from "ant-design-vue/lib/form/useForm";
import type { TableRecord } from "/@/api/models";

export interface FormItemRule {
  required?: boolean;
  message?: string;
  trigger?: string;
  pattern?: RegExp;
  validator?: (rule: FormItemRule, value: any) => Promise<any>;
  max?: number;
  min?: number;
}

export type FormRules = Record<string, FormItemRule[]>;

export interface SelectOptionItem {
  key?: string | number;
  disabled?: boolean;
  value?: string | number;
  title?: string;
  label?: string;
  selected?: boolean;
  //a-cascader option
  isLeaf?: boolean;
  loading?: boolean;
  children?: SelectOptionItem[];
  [key: string]: any;
}

export type FormValidateHandler = (names?: string | string[], option?: validateOptions) => Promise<any>;

export interface SelectCompInstance {
  blur: () => void;
  focus: () => void;
}

export interface BodyCellOptions<T = TableRecord> {
  text: any;
  //控制下拉操作菜单显隐
  record: T & { operVisible?: boolean };
  index: number;
  column: TableColumnProps<T>;
}

export interface HeaderCellOptions {
  column: TableColumnProps;
  title: string;
}
